package utils;

/**
 * LeetCode提供的模板
 */
public class ListNode {
    public int val;
    public ListNode next;

    public static ListNode getListNode(int[] nums) {
        ListNode root = new ListNode(0, null);
        ListNode pos = root;
        for (int num : nums) {
            pos.next = new ListNode(num, null);
            pos = pos.next;
        }
        return root.next;
    }

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    @Override
    public String toString() {
        return "ListNode{" +
                "val=" + val +
                ", next=" + next +
                '}';
    }
}